package com.dream.xiaobo.entity;

import java.io.Serializable;
import java.math.BigDecimal;

/**
 * @author xiaobo
 * @date 2021/8/26 - 8:06
 * 购物车实体类
 */
public class Cart implements Serializable {

    private static final Long serialVersionUID = 1L;

    private Integer cId;

    private BigDecimal cCount;

    private Integer cNum = 0;

    private Integer uId;

    private Integer pId;

    private Product product;

    public Product getProduct() {

        return product;
    }

    public void setProduct(Product product) {
        this.product = product;
    }

    public Integer getcId() {
        return cId;
    }

    public void setcId(Integer cId) {
        this.cId = cId;
    }

    public BigDecimal getcCount() {

        //获取商品的价格
        BigDecimal price = product.getpPrice();
        //将数量类型转换为BigDecimal类型
        BigDecimal decimal = new BigDecimal(cNum);
        //总计 = 商品价格 * 商品数量
        return decimal.multiply(price);
    }

    public void setcCount(BigDecimal cCount) {
        this.cCount = cCount;
    }

    public Integer getcNum() {
        return cNum;
    }

    public void setcNum(Integer cNum) {
        this.cNum = cNum;
    }

    public Integer getuId() {
        return uId;
    }

    public void setuId(Integer uId) {
        this.uId = uId;
    }

    public Integer getpId() {
        return pId;
    }

    public void setpId(Integer pId) {
        this.pId = pId;
    }

    @Override
    public String toString() {
        return "Cart{" +
                "cId=" + cId +
                ", cCount=" + cCount +
                ", cNum=" + cNum +
                ", uId=" + uId +
                ", pId=" + pId +
                '}';
    }
}

